package ogdkp.actions;

import ogdkp.om.Loot;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;

public class RemoveLootAction extends Action {

	private final TreeViewer viewer;

	private final Loot loot;

	public RemoveLootAction(final Loot loot, final TreeViewer viewer) {
		setText("Remove");
		setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
		        .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
		this.loot = loot;
		this.viewer = viewer;
	}

	@Override
	public void run() {
		loot.removeFromParent();
		viewer.refresh();
	}
}
